/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.openbrew.openbrewrf;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import org.eclipse.persistence.annotations.CascadeOnDelete;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "AllocationTemplate")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AllocationTemplate.findAll", query = "SELECT a FROM AllocationTemplate a"),
    @NamedQuery(name = "AllocationTemplate.findByAtid", query = "SELECT a FROM AllocationTemplate a WHERE a.atid = :atid"),
    @NamedQuery(name = "AllocationTemplate.findByATDesc", query = "SELECT a FROM AllocationTemplate a WHERE a.aTDesc = :aTDesc"),
    @NamedQuery(name = "AllocationTemplate.findByATCGroup", query = "SELECT a FROM AllocationTemplate a WHERE a.aTCGroup = :aTCGroup")})
public class AllocationTemplate implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ATID")
    private Integer atid;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 250)
    @Column(name = "ATDesc")
    private String aTDesc;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ATCGroup")
    private int aTCGroup;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ATRepititionType")
    private int repType;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ATRepCount")
    private int repCount;
    @OneToMany(cascade=CascadeType.ALL, orphanRemoval = true)
    @CascadeOnDelete
    @JoinTable(
        name="JTATToATCust",
        joinColumns={ @JoinColumn(name="ATID", referencedColumnName="ATID")},
        inverseJoinColumns={ @JoinColumn(name="ATCustID", referencedColumnName="ATCustID", unique=true)}
    )
    private List<ATCust> atCustCollection;

    public AllocationTemplate() {
    }

    public AllocationTemplate(Integer atid) {
        this.atid = atid;
    }

    public AllocationTemplate(Integer atid, String aTDesc, int aTCGroup) {
        this.atid = atid;
        this.aTDesc = aTDesc;
        this.aTCGroup = aTCGroup;
    }

    public Integer getAtid() {
        return atid;
    }

    public void setAtid(Integer atid) {
        this.atid = atid;
    }

    public String getATDesc() {
        return aTDesc;
    }

    public void setATDesc(String aTDesc) {
        this.aTDesc = aTDesc;
    }

    public int getATCGroup() {
        return aTCGroup;
    }

    public void setATCGroup(int aTCGroup) {
        this.aTCGroup = aTCGroup;
    }

    public List<ATCust> getAtCustCollection() {
        return atCustCollection;
    }

    public void setAtCustCollection(List<ATCust> atCustCollection) {
        this.atCustCollection = atCustCollection;
    }

    public int getRepType() {
        return repType;
    }

    public void setRepType(int repType) {
        this.repType = repType;
    }

    public int getRepCount() {
        return repCount;
    }

    public void setRepCount(int repCount) {
        this.repCount = repCount;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (atid != null ? atid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AllocationTemplate)) {
            return false;
        }
        AllocationTemplate other = (AllocationTemplate) object;
        if ((this.atid == null && other.atid != null) || (this.atid != null && !this.atid.equals(other.atid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.AllocationTemplate[ atid=" + atid + " ]";
    }
    
}
